<?php
    require_once "config.php";
    error_reporting(0);
    /*require_once 'class/Member.php';
    require_once 'class/class.phpmailer.php';*/
    $memberobj=new Member();
    $offer_obj = new Offer();

    $error_msg = "";

    if(empty($_POST)){    
        $_SESSION['my_order_order_id']="";    //used to keep track of the order id which comes from the 'my order' section to update the in-complete orders
    }


    $offer_prefix = trim($_GET['offer_prefix']);
    $order_id = trim($_GET['oid']);
    $change_button=trim((isset($_POST['change_button'])?$_POST['change_button']:""));
    
    /*below condition will be used to auto fill the buynow page form with the incomplete order details.
     * this will happen only if it is not a post back (ie. checkout button clicked or redeem box form submit)
     */
    if (!empty($order_id) && !isset($_POST["checkout"]) && empty($change_button)){  //comes from the My Orders section (Incomplete orders)        
        $incomplete_order=$offer_obj->get_order_details($order_id);
        $_POST=$incomplete_order;   
        $_SESSION['my_order_order_id']=$incomplete_order['order_id'];
    }
    
    if($offer_prefix == '' || !($offer_obj->is_active_offer($offer_prefix))) {
       echo "<p>This offer is not active at the moment</p>";
        exit;
    }

    $offer_details = $offer_obj->get_offer_details_by_prefix($offer_prefix);
    $noofallowedpurchaes=($offer_details["maximum_purchases"]>5)?5:$offer_details["maximum_purchases"];
    
    if(isset($_SESSION['member_id']) && empty($order_id)){  //user has to be loggeed in and should not be an incomplete order coming from the 'My Orders' section.
        $ordered_offers=$offer_obj->offers_ordered_by_a_user($_SESSION['member_id'], $offer_details['offer_id']);
    }
    $offer_count_exceede=FALSE;
    if($ordered_offers>=$offer_details['offers_per_user']){
        $offer_count_exceede=true;
    }
   // print_r($offer_details);
   /* echo '<pre>';
   
    echo '</pre>';*/
  //  exit;
    if($offer_details == FALSE) {
        $error_msg="Offer does not exist";
        /* header("Location:index.php");
        exit;*/
    } else if($offer_details['offer_status'] == 'A' ) {
               $you_saved = $offer_details['regular_amount'] - $offer_details['discount_amount'];
               $discount_percentage = ceil((($offer_details['regular_amount'] - $offer_details['discount_amount'])/$offer_details['regular_amount'])*100);
               $item_sold = $offer_obj->get_noof_sold_items($offer_details['offer_id']);
    } else {
        $error_msg = "This offer already exired or sold out";
    }
 //exit("login: ".$_POST["login"]);
 if(isset($_POST["login"]))
 {

        $en_key = '&56TCVH%#*P*W&vddbsd&^%';
        $enc = new Encryption;
        $loginerrorarr=array();
        if(empty($_POST["username"]) || $_POST["username"]=="username")
        {
            $loginerrorarr["invalidup"]=" Invalid Username Or password!";
        }
        if(empty($_POST["password"])|| $_POST["password"]=="password")
        {
            $loginerrorarr["invalidup"]=" Invalid Username Or password!";
        }

        if(!$loginerrorarr)
        {
            $member=$memberobj->member_login_validate($_POST["username"],str_replace("'", "''", $enc->encrypt($en_key, $_POST["password"])));
            //print_r($member);
                    if($member)
                    {
                        $_SESSION['member_id'] = $member['member_id'];
                        $_SESSION['first_name'] = $member['first_name'];
                        $_SESSION['last_name'] = $member['last_name'];
                        $_SESSION['member_email'] = $member['member_email'];
                        $_SESSION['contact_number'] = $member['contact_number'];
                        $_SESSION['pending_credit'] = $member['pending_credit'];
                    }
                else
                     {

                        $loginerrorarr["invalidup"]=" Invalid Username Or password!";

                     }


        }


 }
 if(isset($_POST["signUpButton"]))
 {
      $en_key = '&56TCVH%#*P*W&vddbsd&^%';
        $enc = new Encryption;
        $validation_obj = new Validation();
        $validation_error = array();
        $user_values = $_POST;
       // print_r($user_values);exit;
        foreach ($user_values as $key => $value) {
            if($validation_obj->check_blank(trim($value) == true)) {
                    $validation_error[$key] = "<span class='error'>$key is blank</span>";
            }
        }

        
       unset($validation_error['username'],$validation_error['password'],$validation_error['terms_and_conditions']);
        if($validation_obj->validate_email($user_values['user_email']) == false) {
            $validation_error['user_email'] = "<span class='error'>Please enter Valid Email</span>";
        }

        if(trim($user_values['user_password']) == '') {
            $validation_error['user_password'] = "<span class='error'>Please enter Password</span>";
        }
        if($user_values['user_password'] != $user_values['confirm_password']) {
            $validation_error['confirm_password'] = "<span class='error'>Both password should be same</span>";
        }
        if($memberobj->member_exist(trim($user_values['user_email'])) != false) {
            $validation_error['user_email'] = "<span class='error'>This email already exist in the system</span>";
        }
        if(trim($user_values['contact_number2']) == '') {
            $validation_error['contact_number2'] = "<span class='error'>Please enter Contact Number</span>";
        }
        if(!isset($user_values['tc2'])) {
            $validation_error['tc2'] = "<span class='error'>Please Agree to T&C to proceed</span>";
        }
        $img = new Securimage();
        $valid = $img->check($_POST['image_code']);

        if($valid == FALSE) {
          $validation_error['image_code'] = "<span class='error'>Sorry, the code you entered was invalid</span>";
        }
      //  print_r($validation_error);exit;
        if(empty($validation_error)) {
            $_SESSION['user_verification'] = 'success'; 
            if(isset($_SESSION['referrer_member_id'])){
                $referrer_details_arr=array("invited_by"=>$_SESSION['referrer_member_id'], "invite_credited"=>'N');
            }
            $verify_details = array('member_email'=>$user_values['user_email'],
                'creation_date' => date('Y-m-d H:i:s'),
                'last_update' => date('Y-m-d H:i:s'),
                'status' => 'P',
                'first_name'=> $user_values['first_name2'],
                 'last_name'=> $user_values['last_name2'],
                'contact_number' => $user_values['contact_number2'],
                'member_password' => $enc->encrypt($en_key, $user_values['user_password']),
                'member_status' => 'G'

            );
            $verify_details = array_merge($verify_details, $referrer_details_arr);
            
            //exit();
            $memID=$memberobj->create_member($verify_details);
                        $_SESSION['member_id'] = $memID;
                        $_SESSION['first_name'] = $user_values['first_name2'];
                        $_SESSION['last_name'] = $user_values['last_name2'];
                        $_SESSION['member_email'] = $user_values['user_email'];
                        $_SESSION['invited_by'] = $verify_details['invited_by'];
                        $_SESSION['invite_credited'] = $verify_details['invite_credited'];
                        $_SESSION['pending_credit'] = $verify_details['pending_credit'];
                        
            // Encrypt the Source Text
            $encstr = $enc->encrypt($en_key, $user_values['user_email']);
            $to_name = $user_values['user_email'];
            $from_name = 'Hotel With Offers';
            $click_link = 'http://www.hotelswithoffers.com/registration_step_two.php?tmu&#61;'.urlencode($encstr);

           // $from_email = 'exceldatabank@yahoo.com';
           // $email_obj = new EmailFunc($to_name, $to_name, $from_name, $from_email);
            $email_message = "<img src='http://www.hotelswithoffers.com/images/logo.png' /><br/>";
            $email_message .= "Dear " . $to_name . ",<br/><br/>";
            $email_message .= "Thank you for verify with us. <br/>   <br/><br/>";
            $email_message .= "Regards <br/>";
            $email_message .= "hotelswithoffers   Team.\n";
   
            // To send HTML mail, the Content-type header must be set
            $subject = 'Email Verification from hotelswithoffers.com';

            $mail = new PHPMailer();
		$mail->IsMail();
		$mail->IsHTML(true);
                $mail->FromName = 'Hotelswithoffers';
                $mail->From = 'hotelswithoffers.com';
		$mail->AddAddress($user_values['user_email']);
                $mail->AddCC('induneth87@gmail.com');
		$mail->Subject = $subject;
		$mail->Body = $email_message;
		//print_r($mail->Send());
		if(!$mail->Send())
		{
		   echo "Error sending: " . $mail->ErrorInfo;;
		}
                else{
                    $mail->ClearAddresses();
                    $mail->ClearAttachments();
                }
            

            }
     
 }
 //print_r($_SESSION);
 if(isset($_POST["checkout"]))
 {

        $orderprocessarray=array();
        if(!isset($_POST['terms_and_conditions'])) {
            $validation_error['terms_and_conditions'] = "<span class='error'>Please Agree to T&C to proceed</span>";
        }
        if($offer_details['isfreeoffer']<>1){
            if(!isset($_POST['payment_option'])) {
                $validation_error['payment_option'] = "<span class='error'>Please select a payment option</span>";
            }
        }
       // print_r($validation_error);
        if(empty($validation_error))
        {
             $orderprocessarray["offer_id"]=$offer_details["offer_id"];
             $orderprocessarray["offer_title"]=$offer_details["offer_id"];
             $orderprocessarray["hotel_id"]=$offer_details["offer_id"];
             $orderprocessarray["offer_start_date"]=$offer_details["offer_start_date"];
             $orderprocessarray["offer_end_date"]=$offer_details["offer_end_date"];
             $orderprocessarray["no_of_offer_vouchers"]=  isset($_POST["no_of_offer_vouchers"])?$_POST["no_of_offer_vouchers"]:0;
             $orderprocessarray["regular_amount"]=$offer_details["regular_amount"];
             $orderprocessarray["discount_amount"]=$offer_details["discount_amount"];
             $orderprocessarray["credits_redeemed"]=  isset($_POST["credits_redeemed"])?$_POST["credits_redeemed"]:0;   
             $orderprocessarray["order_attempts"]=  (empty($_POST["order_attempts"])?0:$_POST["order_attempts"])+1;
             $orderprocessarray["member_id"]=$_SESSION["member_id"];
             $orderprocessarray["first_name"]=$_SESSION["first_name"];
             $orderprocessarray["last_name"]=$_SESSION["last_name"];
             $orderprocessarray["member_email"]=$_SESSION["member_email"];
             $orderprocessarray["contact_number"]=$_SESSION["contact_number"];
             $orderprocessarray["invited_by"]=$_SESSION["invited_by"];
             $orderprocessarray["invite_credited"]=$_SESSION["invite_credited"];
             if($offer_details["isfreeoffer"]==1)
             {
                 $orderprocessarray["isfreeoffer"]=1;
             }             
             $_SESSION["orderprocessarray"]=$orderprocessarray;
             if(!empty($_SESSION['my_order_order_id'])){
                $offer_obj->update_offer_order($_SESSION["orderprocessarray"], $_SESSION['my_order_order_id']);
                $orderid=$_SESSION['my_order_order_id'];
             }else{
                $orderid=$offer_obj->addofferorder($_SESSION["orderprocessarray"]);
             }
             $_SESSION["orderprocessarray"]["orderid"]=$orderid;

               //print_r( $_SESSION["orderprocessarray"]);
                 header("Location:ordersummary.php");
                  
  
            
        }
 }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hotels With Offers</title>
<script language="Javascript" type="text/javascript" src="js/jquery-1.4.1.js"></script>

<script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />

<script language="javascript" type="text/javascript">
        function submitform(form)
        {
            document.getElementById('change_button').value='1';            
            form.submit();
        }
         function check_member(member_email) {
            $.ajax({
            url: "extra_functions.php",
            type: "POST",
            cache: false,
            async:false,
            data: {member_email:member_email,member_check:true },
            success: function(theResponse)
            {
                if(theResponse == 'available'){
                    $('#email_error').html('<span class="error">This email already exist in the system</span>');
                    } else {
                        $('#email_error').html('');
                    }
                }
             });
        }
</script>
</head>

<body>
<div id="wrapper">
<?php require_once 'top_header.php'; ?>
    
<div class="contentPane">
  <div id="sidebar">
    <span class="menu"><img src="images/call.png" alt="Advertise with Hotel with Offers" class="callus"  /></span>
    <div class="joinus">
      <h1>INVITE A FRIEND</h1>
      <h2>Tell a friend and win Rs100.00</h2>
      <div class="joinbtn"><a href="#">LEARN&nbsp;MORE</a></div>
     </div>
    <div class="reserve"><span class="reserveitem">Reserved for :</span> <span class="reserveitem">advertising</span> <span class="reserveitem">latest news</span> <span class="reserveitem">soon ending deals &amp; offers</span></div>
  </div>
  <div class="leftPane">
      <div class="mainMenu"><?php require_once 'main_menu.php'; ?></div>
    <?php require_once 'newsletter_plug.php'; ?>
    <?php if(isset($error_msg)):?>
        <div class="error"><?php echo $error_msg; ?></div>
        <div class="clear"></div>
    <?php endif;?>
    <div class="clear"></div>
    <?php if($offer_count_exceede):?>
    <div class="error"><font size="3" color="red"><p>Maximum number of times a user can order this offer is: <?php echo $offer_details['offers_per_user'];?><br />Click <a href="alloffers.php">here</a> to got to Offers.</p></div>
    <?php else:?>
    <form action="<? $_SERVER["PHP_SELF"] ?>" method="post" name="member_login">
 <?php  if(isset($_SESSION["member_email"])): ?>
<div class="cart">
  <h2>PACKAGE INFORMATION
      <?php 
      $credits_redeemed=isset($_POST['credits_redeemed'])?$_POST['credits_redeemed']:0;
      $pending_credit=isset($_SESSION['pending_credit'])?$_SESSION['pending_credit']:0;
      if ($credits_redeemed>$pending_credit){
          $my_available_credits=0;
      }else{
          $my_available_credits = $pending_credit - $credits_redeemed;
      }
            //echo "my_available_credits:".$my_available_credits.":"
      ?>
  </h2><?php if ($my_available_credits>=0) :?><h5>My available credits: <?php echo $my_available_credits ?></h5><?php endif;?>
  <div class="row">
    <div class="package">
      <h1>&nbsp;</h1>
    </div>
    <div class="price">
      <h1>Price</h1>
    </div>
    <div class="price">
      <h1>Quantity</h1>
    </div>
    <?php 
    //echo "pending_credit: ".$_SESSION['pending_credit'];
    //echo "pending_credit: ".$_SESSION['pending_credit'];
    if(isset($_SESSION['pending_credit']) && $_SESSION['pending_credit']>0 && $offer_details['isfreeoffer']==0):?>
    <div class="price">
      <h1>Redeem</h1>
    </div>
    <?php endif; ?>
    <div class="price">
      <h1>Total</h1>
    </div>
    <div class="clear"></div>
  </div>
  <div class="row">
    <div class="package">
      <p><?php echo $offer_details['offer_title']; ?></p>
    </div>
    <div class="price">
      <p>Rs.<?php echo $offer_details['discount_amount']; ?></p>
    </div>
    <div class="price" align="center">
        <p><?php// echo "<br>noofallowedpurchaes: ".$noofallowedpurchaes;?>
            <input type="hidden" name="change_button" id="change_button">
          <select class="field" name="no_of_offer_vouchers" id="no_of_offer_vouchers" onchange="submitform(this.form);">
              <?php for($i=1;$i<=$noofallowedpurchaes;$i++):?>
              <option <?= $_POST["no_of_offer_vouchers"]==$i?"selected":""?> value="<?php echo $i;?>"><?php echo $i;?></option>
              <?php endfor;?>
          </select>
       
      </p>
    </div>
    <?php if(isset($_SESSION['pending_credit']) && $_SESSION['pending_credit']>0 && $offer_details['isfreeoffer']==0):?>
    <div class="price">
        <input type="hidden" name="credits_available" id="credits_available" value="<?php echo isset($_SESSION['pending_credit'])?$_SESSION['pending_credit']:0;?>">
        <p><input type="text" class="field" name="credits_redeemed" id="credits_redeemed" value="<?php echo (isset($_POST['credits_redeemed']))? $_POST['credits_redeemed']:0; ?>" onblur="submitform(this.form);" style="width: 60px; text-align: right;" /></p>
    </div><div id="credits_msg" name="credits_msg" style="display:none"></div>
    <?php endif; ?>
    <div class="price">
      <p>Rs.<?php echo (isset($_POST["no_of_offer_vouchers"]))? $_POST["no_of_offer_vouchers"]*$offer_details['discount_amount']-(isset($_POST['credits_redeemed'])?$_POST['credits_redeemed']:0):$offer_details['discount_amount']-(isset($_POST['credits_redeemed'])?$_POST['credits_redeemed']:0); ?></p>
    </div>
    <br class="clear" />
    <input name="order_attempts" id="order_attempts" type="hidden" value="<?php echo isset($_POST['order_attempts'])?$_POST['order_attempts']:0?>">
  </div>
</div>
        <?php if($offer_details['isfreeoffer']<>1):?>
            <div class="cart">
              <h2>PAYMENT OPTIONS</h2>
              <ul>
                <li>
                    <input   <?= (strtolower($_POST['payment_option'])=="credit_card")?"checked":"";?> type="radio" name="payment_option" id="cc" value="credit_card"/>
                  Credit Card</li>

                <li>
                    <input  <?= (strtolower($_POST['payment_option'])=="bank_transfer")?"checked":"";?> type="radio" name="payment_option" id="checkbox4" value="bank_transfer" />
                  Direct Bank Transfer
                </li>

              </ul>
              <?php echo isset($validation_error['payment_option'])?"<font color='red'>".$validation_error['payment_option']."</font>":""; ?>
            </div>
        <?php endif;?>
<?php endif;?>
<div class="cart">
 <?php  if(!isset($_SESSION["member_email"])): ?>
  <h2>ACCOUNT INFORMATION</h2>

  <div id="TabbedPanels1" class="TabbedPanels">
   
    <ul class="TabbedPanelsTabGroup">
      <li class="TabbedPanelsTab" tabindex="0">Create an account now</li>
      <li class="TabbedPanelsTab" tabindex="1">Login</li>
    </ul>
    <div class="TabbedPanelsContentGroup">
      
      <div class="TabbedPanelsContent">
        <div class="signUpForm">
           
          <div class="block">
            <p>First Name</p>
            <p>
              <input name="first_name2" class="field" id="first_name2" type="text" value="<?= isset($user_values['first_name2'])?$user_values['first_name2']:"";?>" />
              <?php echo isset($validation_error['first_name2'])?"Please Enter your first name !":""; ?>
            </p>
          </div>
          <div class="block">
            <p>Last Name</p>
            <p>
              <input name="last_name2" class="field" id="last_name2" type="text" value="<?= isset($user_values['last_name2'])?$user_values['last_name2']:"";?>"  />
            <?php echo isset($validation_error['last_name2'])?"Please Enter your last name !":""; ?>
            </p>
          </div>
          <div class="block">
            <p>Your Email</p>
            <p>
              <input name="user_email" class="field" id="user_email" value="<?= isset($user_values['user_email'])?$user_values['user_email']:"";?>" onblur="check_member(this.value);" type="text" />
              &nbsp; <?php echo isset($validation_error['user_email'])?$validation_error['user_email']:""; ?> <span id="email_error"></span></p>
          </div>
          <div class="block">
            <p>Password</p>
            <p>
              <input name="user_password" class="field" id="user_password" type="password" />
              &nbsp;  <?php echo isset($validation_error['user_password'])?$validation_error['user_password']:""; ?></p>
          </div>
          <div class="block">
            <p>Confirm Password</p>
            <p>
              <input name="confirm_password" id="confirm_password" class="field" type="password" />
              &nbsp;  <?php echo isset($validation_error['confirm_password'])?$validation_error['confirm_password']:""; ?></p>
          </div>
          <div class="block">
            <p>Phone Number</p>
            <p>
              <input name="contact_number2" id="contact_number2" type="text" value="<?= isset($user_values['contact_number2'])?$user_values['contact_number2']:"";?>" class="field" />
            <?php echo isset($validation_error['contact_number2'])?$validation_error['contact_number2']:""; ?>
            </p>
          </div>
          <div class="block">
            <p>
              <input id="subscribe" name="subscribe" type="checkbox" checked="checked" value="1" title="Sign Up for HotelsWithOffers Newsletter" />
              &nbsp;Send me hotelswithoffers.com Offers </p>
          </div>
          <div class="block">
            <p>
              <input <?= isset($user_values['tc2'])?"checked":"";?> id="tc2" name="tc2" type="checkbox"  value="1" title="Accept Terms and Conditions" />
              &nbsp;I aggreed to the <a href="#"> Terms and Conditions</a></p>
              <?php echo isset($validation_error['tc2'])?$validation_error['tc2']:""; ?>
          </div>
          <div class="block"> <img src="securimage_show.php?sid=<?php echo md5(time()) ?>" alt="" align="left" id="siimage" style="padding-right: 5px; border: 0" />
            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="19" height="19" id="SecurImage_as3" align="middle">
              <param name="allowScriptAccess" value="sameDomain" />
              <param name="allowFullScreen" value="false" />
              <param name="movie" value="securimage_play.swf?audio=securimage_play.php&amp;bgColor1=#777&amp;bgColor2=#fff&amp;iconColor=#000&amp;roundedCorner=5" />
              <param name="quality" value="high" />
              <param name="bgcolor" value="#ffffff" />
              <embed src="securimage_play.swf?audio=securimage_play.php&amp;bgColor1=#777&amp;bgColor2=#fff&amp;iconColor=#000&amp;roundedCorner=5" quality="high" bgcolor="#ffffff" width="19" height="19" name="SecurImage_as3" align="middle" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>
              </embed>
            </object>
            <br />
            <!-- pass a session id to the query string of the script to prevent ie caching -->
            <a tabindex="-1" style="border-style: none" href="#" title="Refresh Image" onclick="document.getElementById('siimage').src = 'securimage_show.php?sid=' + Math.random(); return false"><img src="images/refresh.gif" alt="Reload Image" border="0" onclick="this.blur()" align="bottom" /></a> <br class="clear" />
            <div class="block">
              <input type="text" name="image_code" id="image_code" value="Please type in the above code here" class="captcha" />
              <br/>
              <?php echo $validation_error['image_code']; ?></div>
          </div>
          <div class="block">
            <input class="signUpButton" name="signUpButton" value="Sign Up Now" type="submit" class="general_submit" />
          </div>
           
        </div>
      </div>
     <div class="TabbedPanelsContent">
         
        <div class="signUpForm">
           <?php if(isset($loginerrorarr["invalidup"])):?>
            <span class="error"><?php echo $loginerrorarr["invalidup"]?> </span>
            <?php endif;?>
          <div class="block">
            <p>Username</p>
            <p>
              <input name="username" class="field" id="username" type="text" value="" />
            </p>
          </div>
          <div class="block">
            <p>Password</p>
            <p>
                <input name="password" class="field" id="password" type="password" value=""  />
            </p>
          </div>

          <div class="block">
            <input class="signUpButton" name="login" value="Next" type="submit" class="general_submit" />
          </div></div>

      </div>
    </div>
   <?php else:?>         
    <input class="signUpButton" name="checkout" value="checkout" type="submit" class="general_submit" />
    <div class="cart">
        <h2>Terms &amp; Conditions</h2>
        <p>
        <input <?php echo (isset ($_POST["terms_and_conditions"]))?"checked":""?> type="checkbox" name="terms_and_conditions" id="terms_and_conditions" value="1" />
        I accept the Terms of Sale &amp; the Terms mentioned on the Package</p>
        <?php echo isset($validation_error['terms_and_conditions'])?"<font color='red'>".$validation_error['terms_and_conditions']."</font>":""; ?>
        <p>By accepting the above terms &amp; conditions, I have read and agreed to all the terms and conditions set forth by ...</p> 
    </div>
   <?php endif;?>
    </div>
  </div>
</form>
<?php endif;?>
<div class="clear"></div>
</div>
<div class="clear"></div>

</div>
</div>
<div class="clear"></div>

<div id="footerWrapper">
<?php require_once 'footer.php'; ?>
</div>
    <script language="javascript" type="text/javascript">
        var TabbedPanels1 = new Spry.Widget.TabbedPanels("TabbedPanels1");
    </script>
</body>
<script language="javascript" type="text/javascript">
    
$(document).ready(function() {    
    $("#credits_redeemed").keyup(function(event){                
        if(parseInt($("#credits_redeemed").val(), 10) > parseInt($("#credits_available").val(), 10)){
            $('#credits_msg').show();
            $('#credits_msg').html('Maximum redeemable points: '+$('#credits_available').val());
            $('#credits_msg').html();            
            $('#credits_redeemed').val($('#credits_available').val());            
        }else{
            $('#credits_msg').hide();
        }
    });   
});    
</script>
</html>
